﻿using System;
using ServicesComponent.Repositories;
using System.Web.Services;

public partial class QuanLyDinhDuong_ThucPhamList : System.Web.UI.Page
{
    public int id = 1;
    private static IThucPhamRepository _ThucPhamRepository;

    protected void Page_Init(object sender, EventArgs e)
    {
        Cpage.PageSize = Constant.RowPerPage;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["Page"] != null)
        {
            id = (int.Parse(Request.QueryString["Page"].ToString()) - 1) * Constant.RowPerPage + 1;
        }
        _ThucPhamRepository = FactoryServices.GetServicesThucPham(_ThucPhamRepository);
        if (!IsPostBack)
        {
            if (Request.QueryString["Refresh"] != null)
            {
                Bind();
                return;
            }
        }
        Bind();
    }

     void Bind()
    {
        rptA.DataSource = _ThucPhamRepository.GetList();
        rptA.DataBind();
        Cpage.DataSource = _ThucPhamRepository.GetList();
        Cpage.BindToControl = rptA;
        rptA.DataSource = Cpage.DataSourcePaged;
    }
}